<?php
include_once "common.php";
//数组[key1=>value1,key2=>value2, ...]
//若未指定key，将自动使用之前用过的最大int键名加上1作为新的键名，第一个整数key值是0
$a=[111,3.5,100=>"hello",true];
var_dump($a);
$a=['name'=>'张三','age'=>18,'sex'=>'男'];
print_r($a);
$a=['24jsj2','name'=>'张三',0=>'24jsj2','name'=>'蔡徐坤',];
print_r($a);

$array = array(
    1 => 'a',
    '1' => 'b',
    1.5 => 'c',
    -1 => 'd',
    '01'=> 'e',
    '1.5' =>'f',
    true =>'g',
    false =>'h',
    '' =>'i',
    null =>'j',
    'k',
    2 =>'l',
);
p($array);
//数组的便利显示
$a=[111,222,333,"hello",true];
for($i=0, $len=count($a);$i<$len;++$i){
    echo $i, '. ',$a[$i], "\n";
}
echo"-------------------------\n";
$a=[111,222,10=>333,"Hello",true];
foreach($a as $v){
    echo $v,"\n";
}
echo"-------------------------\n";
$a=[111,'name'=>'zhangsan',345,'age'=>18];
foreach($a as $key=>$value){
    echo $key, '--->',$value,"\n";
}
